require('./Girdview.styl');
import { Control } from 'react-keeper';
import { Grid } from 'saltui'
const Storage = require('clientConfig/util/StoreData').Storage;
const classNames = require("classnames")
const handleClickItem = (fn, index, selected) => {
    if (fn) {
         fn(index, selected);//courseList:selected==true或false，itemsList传id       
    }
}
const Girdview = (props) => {
    let { girdItems, addPhoto, handleClick, type, activeId } = props;
    if (!girdItems) return;
    return (
        <div className="girdview">
            <Grid className="ft14" col={props.col} square={true} touchable={props.touchable || false} noLine={true}>
                {girdItems && girdItems instanceof Array && girdItems.map((item, index) => {
                    return (
                        <div
                            className={classNames("girdview-item t-FAC omt", { "itemsList": type == "itemsList" }, { "selected": type == "courseList" && item.selected }, { "selected": type == "itemsList" && activeId && item.id == activeId })}
                            onClick={
                                () => {
                                    handleClickItem(handleClick, index, type == "courseList" ? item.selected : item.id)
                                }}
                            data-id={index}
                        >
                            {item.courseName || item.name}
                        </div>);
                })}
            </Grid>
        </div>);
}
module.exports = Girdview;
